<template>
   <el-select
    :value="value"
    @change="changeChannel"
    clearable
    placeholder="请选择">
     <el-option
        v-for="item in channelOptions"
        :key="item.id"
        :label="item.name"
        :value="item.id">
      </el-option>
    </el-select>
</template>
<script>
export default {
  name: 'MyChannel',
  props: ['value'],
  data () {
    return {
      channelId: null,
      channelOptions: []
    }
  },
  created () {
    this.getChannelOptions()
  },
  methods: {
    async getChannelOptions () {
      const res = await this.$http.get('/v1_0/channels')
      // console.log(res.data.data.channels)
      this.channelOptions = res.data.data.channels
    },
    changeChannel (channelId) {
      // console.log(channelId)
      this.$emit('input', channelId)
    }
  }
}
</script>
<style scoped lang="less"></style>
